package com.ejior.bluetea.receiver;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.ejior.bluetea.bean.BLEDevice;

/**
 * Created by kevin on 2017/8/27.
 */

public class BluetoothReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        //  搜索到的蓝牙设备
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            // 未绑定的蓝牙设备
            if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
                BLEDevice bleDevice = new BLEDevice();
                bleDevice.setDeviceName(device.getName());
                bleDevice.setMac(device.getAddress());

            }
            // 搜索结束
        } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {

        }
    }
}
